package flc.ast;

import android.view.View;
import android.widget.RelativeLayout;

import androidx.annotation.NonNull;

import com.blankj.utilcode.util.ConvertUtils;
import com.blankj.utilcode.util.ScreenUtils;

import java.util.ArrayList;
import java.util.List;

import flc.ast.databinding.ActivityHomeBinding;
import flc.ast.fragment.FormatFragment;
import flc.ast.fragment.HomeFragment;
import flc.ast.fragment.MyFragment;
import flc.ast.fragment.PlayFragment;
import stark.common.basic.base.BaseNoModelActivity;
import stark.common.basic.base.BaseTabFragmentHomeActivity;
import stark.common.basic.base.DefExitAppDialog;
import stark.common.basic.event.EventStatProxy;
import stark.common.basic.event.IEventStat;
import stark.common.basic.utils.StatusBarUtils;

public class HomeActivity extends BaseTabFragmentHomeActivity<ActivityHomeBinding> implements View.OnClickListener {


    @NonNull
    @Override
    protected List<BaseTabFragmentHomeActivity<ActivityHomeBinding>.FragmentViewBinder> getFragmentViewBinders() {
        List<FragmentViewBinder> listFragment=new ArrayList<>();
        listFragment.add(new FragmentViewBinder(HomeFragment.class,R.id.ivHome));
        listFragment.add(new FragmentViewBinder(FormatFragment.class,R.id.ivFormat));
        listFragment.add(new FragmentViewBinder(PlayFragment.class,R.id.ivPlay));
        listFragment.add(new FragmentViewBinder(MyFragment.class,R.id.ivMy));
        return listFragment;
    }

    @Override
    protected void onHandleStatusBar() {
        StatusBarUtils.setStatusBarTranslate(this);
        StatusBarUtils.setSystemStatusTextColor(true, this);
    }

    @Override
    protected void onFragmentViewClick(View view) {
        clearSelection();
        switch (view.getId()){
            case R.id.ivHome:
                mDataBinding.ivHome.setImageResource(R.drawable.tab_spbj2);
                mDataBinding.llHome.setBackgroundResource(R.drawable.tab_xz);
                break;
            case R.id.ivFormat:
                mDataBinding.ivFormat.setImageResource(R.drawable.tab_spzh2);
                mDataBinding.llFormat.setBackgroundResource(R.drawable.tab_xz);
                break;
            case R.id.ivPlay:
                mDataBinding.ivPlay.setImageResource(R.drawable.tab_spbf2);
                mDataBinding.llPlay.setBackgroundResource(R.drawable.tab_xz);
                break;
            case R.id.ivMy:
                mDataBinding.ivMy.setImageResource(R.drawable.tab_grzx2);
                mDataBinding.llMy.setBackgroundResource(R.drawable.tab_xz);
                break;
        }
    }

    @Override
    protected int getFragmentContainerId() {
        return R.id.flHome;
    }

    @Override
    protected int onCreate() {
        return R.layout.activity_home;
    }

    private void clearSelection(){
        mDataBinding.ivHome.setImageResource(R.drawable.tab_spbj1);
        mDataBinding.llHome.setBackground(null);
        mDataBinding.ivFormat.setImageResource(R.drawable.tab_spzh1);
        mDataBinding.llFormat.setBackground(null);
        mDataBinding.ivPlay.setImageResource(R.drawable.tab_spbf1);
        mDataBinding.llPlay.setBackground(null);
        mDataBinding.ivMy.setImageResource(R.drawable.tab_grzx1);
        mDataBinding.llMy.setBackground(null);
    }

}